<?php 
	session_start(); 
	if (!$_SESSION["id_no"])
    {
        Header("Location: index.php");
    }
	else{
		if ($_SESSION['account_type']=='root'){
			$header="secured/header_login";
			$admin="yes";
		}
		elseif($_SESSION['account_type']=='Admin'){ 
			$header="secured/header_login";
			$admin="yes";
		}else{
			$header="header";
			$admin="no";
		}
	}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Ralimo System Panel</title>
<link rel="stylesheet" href="css/screen.css" type="text/css" media="screen" title="default" />
<link rel="stylesheet" href="css/jquery-ui-1.8.21.custom.css" type="text/css" media="screen" title="default" />
<!--[if IE]>
<link rel="stylesheet" media="all" type="text/css" href="css/pro_dropline_ie.css" />
<![endif]-->
<!--  jquery core -->
<script src="js/jquery/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/jquery/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>
<!--  date picker script -->
<link rel="stylesheet" href="css/datePicker.css" type="text/css" />
<script type="text/javascript" src="js/jquery/infowindow.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#vehicle_type").autocomplete({
			source: "query/getvehicletype.php",
			minLength: 2,
			open: function(){
				$(this).removeClass("ui-corner-all").addClass("ui-corner-top");
			},
			close: function(){
				$(this).removeClass("ui-corner-all").addClass("ui-corner-top");
			}
		
		});
		
		$("#city_name").autocomplete({
			source: "query/getcity.php",
			minLength: 2,
			open: function(){
				$(this).removeClass("ui-corner-all").addClass("ui-corner-top");
			},
			close: function(){
				$(this).removeClass("ui-corner-all").addClass("ui-corner-top");
			}
		
		});
		
	});
</script>
</head>
<body> 
<?php 
	include"template/$header.php"; 
	include("query/db_connection.php");		

	$ralimo_id = $_GET['id'];
	
	$sql = "SELECT 
				ra.id,
				ra.cityname, 
				ra.vehicletype, 
				ra.vehiclemodel, 
				ra.capacity, 
				ra.cancellationpolicy, 
				ra.availability,
				rd.id,
				rd.destination,
				rd.currency,
				rd.ralimorateid,
				rd.rate
				FROM 
				ralimorates ra
				INNER JOIN ralimoratesdetail AS rd ON ra.id = rd.ralimorateid
				WHERE
				 rd.id = '$ralimo_id'
				 ";
	$res = mysql_query($sql);
	$row =  mysql_fetch_array($res);
		$id = $row['ralimorateid'];
		$cityname = $row['cityname'];
		$vehicletype = $row['vehicletype'];
		$vehiclemodel = $row['vehiclemodel'];
		$capacity	= $row['capacity'];
		$destination = $row['destination'];
		$cancellation_policy  = $row['cancellationpolicy'];
		$minimum_hour = $row['minimumhr'];
		$rate = $row['rate'];
	
	if(isset($_POST['button'])){
		$id = $_POST['id'];
		$ralimo_id = $_POST['ralimo_id'];
		$city_name = $_POST['city_name'];
		$vehicle_type = $_POST['vehicle_type'];
		$vehicle_model = $_POST['vehicle_model'];
		$capacity = $_POST['capacity'];
		$cancellation_policy = $_POST['cancellation_policy'];
		$destination = $_POST['destination'];
		
		$sql2 = "UPDATE
				 ralimorates AS r, ralimoratesdetail AS rd
				 SET
				 r.cityname = '$city_name',
				 r.vehicletype = '$vehicle_type',
				 r.vehiclemodel = '$vehicle_model',
				 r.capacity = '$capacity',
				 r.cancellationpolicy = '$cancellation_policy',
				 rd.vehicletype = '$vehicle_type',
				 rd.destination = '$destination',
				 rd.rate = '$rate'
				 WHERE
				 r.id = '$id'
				 AND
				 rd.id = '$ralimo_id'
				 AND
				 rd.ratetype = 'short' ";
		mysql_query($sql2);
		echo "<script type='text/javascript'>
				window.location.replace('ralimo_short_rates.php');
			  </script>";
	}
?>
  <div class='clear'></div>
<!-- start content-outer ........................................................................................................................START -->
	<div id='content-outer'>
	<!-- start content -->
	<div id='content'>

	<!--  start page-heading -->
	<div id='page-heading'>
		<h1>Edit Short Rate</h1>
	</div>
	<!-- end page-heading -->
	
	<div id="back_affiliate" style="margin-left:1140px; width:100px;">
		<a href="ralimo_short_rates.php"><img src="images/forms/back.png" /></a>
	</div>

	<table border='0' width='100%' cellpadding='0' cellspacing='0' id='content-table'>
	<tr>
		<th rowspan='3' class='sized'><img src='images/shared/side_shadowleft.jpg' width='20' height='300' alt='' /></th>
		<th class='topleft'></th>
		<td id='tbl-border-top'>&nbsp;</td>
		<th class='topright'></th>
		<th rowspan='3' class='sized'><img src='images/shared/side_shadowright.jpg' width='20' height='300' alt='' /></th>
	</tr>
	<tr>
		<td id='tbl-border-left'></td>
		<td>
		<!--  start content-table-inner ...................................................................... START -->
		<div id='content-table-inner'>
						<!--  start step-holder -->
		
		<!--  end step-holder -->
		<!--  start table-content  -->
			<div id='table-content'>
				<form action="" method="post">
					<table border="0" cellpadding="0" cellspacing="0"  id="id-form">
						<tr>
							<td><b>City:&nbsp;</b></td>
							<td><input type="text" name="city_name" id="city_name" autocomplete="off" class="inp-form" value="<?php echo $cityname;?>" /></td>
						</tr>
						<tr>
							<td><b>Vehicle Type:&nbsp;</b></td>
							<td><input type="text" name="vehicle_type" id="vehicle_type" autocomplete="off" class="inp-form" value="<?php echo $vehicletype;?>" /></td>
						</tr>
						<tr>
							<td><b>Vehicle Model:&nbsp;</b></td>
							<td><input type="text" name="vehicle_model" id="vehicle_model" autocomplete="off" class="inp-form" value="<?php echo $vehiclemodel;?>"/></td>
						</tr>
						<tr>
							<td><b>Capacity:&nbsp;</b></td>
							<td><input type="text" name="capacity" id="capacity" autocomplete="off" class="inp-form" value="<?php echo $capacity;?>" /></td>
						</tr>
						<tr>
							<td><b>Destination:&nbsp;</b></td>
							<td><input type="text" name="destination" id="destination" autocomplete="off" class="inp-form" value="<?php echo $destination;?>" /></td>
						</tr>
						<tr>
							<td><b>Rate:&nbsp;</b></td>
							<td><input type="text" name="rate" id="rate" autocomplete="off" class="inp-form" value="<?php echo $rate;?>" /></td>
						</tr>
						<tr>
							<td><b>Cancellation Policy:&nbsp;</b></td>
							<td><input type="text" name="cancellation_policy" id="cancellation_policy" autocomplete="off" class="inp-form" value="<?php echo $cancellation_policy;?>" /></td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td><input id="button" name="button" type="submit" class="form_update" /></td>
							<td><input type="hidden" name="ralimo_id"  value="<?php echo $ralimo_id;?>" /></td>
							<td><input type="hidden" name="id" value="<?php echo $id;?>" /></td>						
						</tr>
					</table>
				</form>	
			<!--  start related-activities -->
			<div id="related-activities" style="margin-top:-220px;">
				<div id="related-act-bottom">
				<div class="clear"></div>		
				</div>
				<!-- end related-act-bottom -->
			
			</div>
			<!-- end related-activities -->

		</td>
		<td id="tbl-border-right"/>
	</tr>
	
	<tr>
		<th class='sized bottomleft'></th>
		<td id='tbl-border-bottom'>&nbsp;</td>
		<th class='sized bottomright'></th>
	</tr>
	</table>
	<div class='clear'>&nbsp;</div>

	</div>
	<!--  end content -->
	<div class='clear'>&nbsp;</div>
	</div>
	<!--  end content-outer........................................................END -->";
				
<!--  start nav-outer-repeat................................................... END -->

  <div class="clear"></div>
 
<!-- start content-outer ........................................................................................................................START -->
<div id="content-outer">
<!-- start content -->
<!--  end content -->
<div class="clear">&nbsp;</div>
</div>
<!--  end content-outer........................................................END -->

<div class="clear">&nbsp;</div>
    
<?php include"template/footer.php"; ?>
 
</body>
</html>


